Skip to content

feat(lambda)!: alias name, alias-only permission default, public alias/version, scoped log policy, S3 artifact code - #115

Merged
ncipollina merged 4 commits into
mainfrom
feat/v3-lambda-function-options
Nov 24, 2026
Merged

ncipollina merged 4 commits into
mainfrom
feat/v3-lambda-function-options

Conversation

@ncipollina

@ncipollina ncipollina commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #110

Beads: cdkc-2lh.3 (epic cdkc-2lh). Design: docs/designs/v3-modernization.md §7, now Accepted (rev 2) with the owner's 2026-11-24 decisions.

Summary

LambdaFunctionConstruct is now usable for least-privilege, artifact-based deployments.

  • U1, alias name: AliasName option, default live. The alias construct ID is unchanged, so its logical ID is stable.
  • U2, permission targets (breaking): LambdaPermission.Targets takes LambdaPermissionTargets flags (Function, Version, Alias). The default is the alias only, per the owner's decision. Function | Version | Alias reproduces the 2.x permission resources exactly. A permission with no targets is rejected.
  • U3, public alias and version: LambdaFunctionConstruct.Alias (IAlias) and .Version (IVersion).
  • U4, scoped log policy (breaking): the execution role may only logs:CreateLogStream and logs:PutLogEvents on the construct's own log group (Fn::GetAtt of the log group's ARN). logs:CreateLogGroup, logs:TagResource and the wildcard log-group ARN are removed.
  • U7, S3 artifact code: an optional Code property as an alternative to AssetPath, e.g. Code.FromBucketV2(bucket, key). Exactly one of the two must be set. AssetPath is no longer required, and existing asset-based usage synthesizes identically. No bucket grants are added.
  • Testing helpers:
    • WithAliasName, WithCode, and an optional targets on WithApiGatewayPermission/WithAlexaPermission;
    • ShouldHaveLambdaPermissions counts per target;
    • ShouldHaveCloudWatchLogsPermissions asserts the scoped policy. Its region/account parameters are kept for source compatibility and are now ignored.
  • Docs:
    • the construct page and the Testing guide;
    • a new Upgrading to 3.0 guide (docs/migration/v3.md) with before/after template excerpts for U2 and U4;
    • README, CLAUDE.md and the MkDocs nav.

Breaking changes (intentional)

  • U2: the function and version AWS::Lambda::Permission resources are gone at the default.
  • U4: the policy document changes.
  • ILambdaFunctionConstructProps: AssetPath is now string?, and the interface gains Code and AliasName.

Golden templates

The changes are limited to U2 and U4, as the acceptance criteria require.

  • Every Lambda golden has the U4 policy change.
  • lambda-permissions.json and lambda-otel-url-permissions.json lose the function/version permissions.
  • New goldens: lambda-permissions-all-targets.json (2.x parity), lambda-alias-name.json and lambda-s3-code.json.
  • Non-Lambda goldens are unchanged.
  • 2.x parity check: the AWS::Lambda::Permission resources extracted from 53607ea:…/lambda-permissions.json and from lambda-permissions-all-targets.json are equal (same logical IDs and properties).

Validation (actually run)

  • TDD: each of U1, U2, U3, U4 and U7 had a test observed failing for the behavioral reason before the implementation (OpenCode worker evidence, re-checked in review):
    • U1: Expected prod but received live;
    • U2: 8 of 9 rows failed with found 3, and the zero-targets test failed because no exception was thrown;
    • U3: Expected object not to be <null>;
    • U4: the old wildcard policy mismatched;
    • U7: Expected my-lambda-artifacts but received cdk-hnb659fds-assets-…, and both rejection tests failed because no exception was thrown.
  • Re-run by Claude on 6fd1273:
    • dotnet build LayeredCraft.Cdk.Constructs.slnx -c Release: 0 warnings, 0 errors;
    • dotnet test --solution LayeredCraft.Cdk.Constructs.slnx -c Release: net10.0 618 passed, net11.0 618 passed, 0 failed (595 per TFM before).
  • git diff --check: clean.
  • Not run: a local MkDocs build (mkdocs isn't installed locally; the Docs workflow builds on main).

Test-stack audit

  • Compono and Compono.XunitV3 only. Existing profile reused; no new packages.
  • Behavior-defining values (alias names, targets, bucket and key) are literals.
  • Retained custom infrastructure: GoldenTemplate and CdkTestHelper. Compono does not provide CloudFormation template diffing or CDK test-asset resolution.

Orchestration

  • Implemented by an OpenCode worker (openrouter/deepseek/deepseek-v4.1-flash) in an isolated worktree with explicit file ownership. The required reads were observed in the worker log.
  • Claude reviewed the committed diff, re-ran validation, and wrote the shared docs, the migration guide and the design status update. (The .beads/issues.jsonl export was later removed: Beads now sync through the Dolt remote, chore(beads): adopt Dolt-backed sync via refs/dolt/data; stop tracking issues.jsonl #117.)
  • Minor items reviewed and accepted:
    • an AssetPath of whitespace together with Code is reported as "both set";
    • two helper parameters are now unused.

🤖 Generated with Claude Code

ncipollina and others added 3 commits November 24, 2026 07:24
- default invocation permissions to alias only with per-permission targets
- add configurable AliasName and public Alias/Version
- scope the execution-role log policy to the construct's log group
- accept S3 artifact Code as an alternative to AssetPath
…eads export

- docs/migration/v3.md: .NET 8/9 removal, CDK 2.278.0 floor and type-name
  collisions, alias-only permission default (U2) and scoped log policy (U4)
  with before/after template excerpts, new options (U1, U3, U7)
- design doc: Accepted rev 2 with the owner's 2026-11-24 decisions; Web
  Function investigation deferred to #114
- README, CLAUDE.md and mkdocs nav updated
- .beads/issues.jsonl export (cdkc-2lh.3 chain, #114 bead)

Refs #110

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ncipollina ncipollina added this to the v3.0.0 milestone Nov 24, 2026
@ncipollina ncipollina added ✨ enhancement New feature or request breaking-change Introduces a breaking change labels Nov 24, 2026
@github-actions github-actions Bot added the type: feat New feature label Nov 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T12:29:53.343070Z a0c818e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ncipollina

Copy link
Copy Markdown
Contributor Author

@codex review — focus: (1) correctness of the U2 permission-target logic and its 2.x parity (logical IDs unchanged for opt-in all-targets); (2) U4: is a policy resource of the log group's Fn::GetAtt Arn (which ends in :*) sufficient for logs:CreateLogStream and logs:PutLogEvents at runtime; (3) U7 AssetPath/Code validation and that existing AssetPath consumers synthesize identically; (4) accuracy of docs/migration/v3.md against the golden templates.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: a0c818ef14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (targets.HasFlag(LambdaPermissionTargets.Version)) targetCount++;
if (targets.HasFlag(LambdaPermissionTargets.Alias)) targetCount++;

template.ResourceCountIs("AWS::Lambda::Permission", permissionCount * targetCount);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a defect: both operands are small counts (permissions × at most 3 targets) passed to ResourceCountIs(string, double); no overflow is possible. No change.

var construct = new LambdaFunctionConstruct(stack, "test-construct", props);
var template = Template.FromStack(stack);

construct.Alias.Should().NotBeNull();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a defect: Alias is a non-nullable IAlias always assigned in the constructor, and the test asserts NotBeNull() two lines earlier; the ?. is redundant but harmless. No change.

@ncipollina

Copy link
Copy Markdown
Contributor Author

Versioning check: this PR's breaking-change label does not cause a 4.0.0

Verified against the current repository state. No change is needed.

How the version is resolved

  • publish-preview (devops-templates v11.2) runs release-drafter@v7.7.0 with dry-run: true and uses resolved_version.
  • It publishes <base>-preview.<run_number>.

Which release is the base

  • Release Drafter v7.7.0 (find-previous-releases.ts) bases the version on the latest published release. Drafts are split off (publishedReleases = filteredReleases.filter((r) => !r.draft)). The existing v3.0.0 draft is only the release that gets updated in place; it is never the base.
  • The latest published release is v2.6.0.

How the bump is computed

Observed

Expected after merging this PR: 3.0.0-preview.<run>, and the v3.0.0 draft gains this PR under ⚠️ Breaking Changes.

The only path to 4.0.0 is a breaking PR merged after v3.0.0 is published as a release, which would be correct.

@ncipollina ncipollina changed the title feat(lambda)!: alias name, alias-only permission default, public alias/version, scoped log policy, S3 artifact code feat(lambda): alias name, alias-only permission default, public alias/version, scoped log policy, S3 artifact code Nov 24, 2026
@ncipollina ncipollina removed the breaking-change Introduces a breaking change label Nov 24, 2026
@ncipollina ncipollina changed the title feat(lambda): alias name, alias-only permission default, public alias/version, scoped log policy, S3 artifact code feat(lambda)!: alias name, alias-only permission default, public alias/version, scoped log policy, S3 artifact code Nov 24, 2026
@ncipollina ncipollina added the breaking-change Introduces a breaking change label Nov 24, 2026
Beads now synchronize through the Dolt remote (refs/dolt/data); the JSONL
export is no longer committed (see the Beads migration PR). Restores the
file to main's version so this PR does not touch it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Introduces a breaking change ✨ enhancement New feature or request type: feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.0.0: LambdaFunctionConstruct alias name, alias-only permissions, public alias, scoped log policy, S3 artifacts

1 participant